package tt.dz.egobus.servicemanager.core;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import tt.dz.egobus.base.cache.CacheConfig;
import tt.dz.egobus.base.config.ContextConfing;
import tt.dz.egobus.servicemanager.base.config.MVCConfig;

/**
 * webapp测试启动类
 * 未启动dubbo服务
 */
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration(value = "src/main/webapp")
@ContextHierarchy({
        @ContextConfiguration(name = "context", classes = ContextConfing.class),
        @ContextConfiguration(name = "caching", classes = CacheConfig.class),
        @ContextConfiguration(name = "mvc", classes = MVCConfig.class)
})
@Rollback(true)
public abstract class AbstractWebAppContextSetupCore {


    @Autowired
    private WebApplicationContext wac;

    public MockMvc mockMvc;

    @Before
    public void setUp() {
        mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    }

}
